package com.woniu.p2p.controller;

import com.github.pagehelper.PageInfo;
import com.woniu.p2p.entity.New;
import com.woniu.p2p.service.NewService;
import com.woniu.p2p.vo.ShowVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 86152
 * @create 2020/8/10
 * @since 1.0.0
 */
@RestController
@RequestMapping("/new")
public class P2PNewController {
    @Autowired
    NewService newService;

    @RequestMapping("/getnewList")
    public PageInfo<New> getnewlist(){
        int start=1;
        int pagesize=7;
        PageInfo<New> newPageInfo=newService.findnewlist(start,pagesize);
        return newPageInfo;
    }

    @RequestMapping("/getsinglenew")
    public New getsinglenew(@RequestBody New singlenew){
        New getsinglenewbyid=newService.getsinglenewbyid(singlenew.getNewId());
        return getsinglenewbyid;
    }

    @RequestMapping("/getsinglepage")
    public PageInfo<New> getsinglepage(@RequestBody ShowVo showVo){
        Integer start = showVo.getPageNum();
        int pagesize=7;
        PageInfo<New> findnewlist = newService.findnewlist(start, pagesize);
        return findnewlist;
    }
}
